unit untRelExtratoIAGRO;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, untRelPadrao, cxGraphics, cxLookAndFeels, cxLookAndFeelPainters,
  Menus, ACBrBase, ACBrEnterTab, DB, IBCustomDataSet, dxmdaset, IBQuery,
  ImgList, ActnList, StdCtrls, cxButtons, ExtCtrls, cxControls,
  cxContainer, cxEdit, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinFoggy,
  dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
  dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSharp, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
  dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinXmas2008Blue, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit,
  cxDBLookupComboBox, cxTextEdit, cxMaskEdit, cxSpinEdit, cxDBEdit,
  cxLabel, cxGroupBox, cxCalendar, ppDB, ppDBPipe, ppEndUsr, ppParameter,
  ppModule, daDataModule, ppBands, ppClass, ppCtrls, ppVar, ppPrnabl,
  ppCache, ppComm, ppRelatv, ppProd, ppReport, ppStrtch, ppSubRpt;

type
  TfrmRelExtratoIAGRO = class(TfrmRelPadrao)
    lstPropriedade: TIBQuery;
    lstPropriedadeCODIGO: TIntegerField;
    lstPropriedadeNOME: TIBStringField;
    lstProdutores: TIBQuery;
    lstProdutoresCODIGO: TIntegerField;
    lstProdutoresNOME: TIBStringField;
    dsProdutor: TDataSource;
    dsPropriedade: TDataSource;
    cxGroupBox1: TcxGroupBox;
    cxLabel2: TcxLabel;
    cbPropriedade: TcxDBLookupComboBox;
    cxLabel6: TcxLabel;
    cbProdutor: TcxDBLookupComboBox;
    mtbFiltroPRODUTOR: TIntegerField;
    mtbFiltroPROPRIEDADE: TIntegerField;
    mtbFiltroDATA1: TDateField;
    mtbFiltroDATA2: TDateField;
    cxLabel1: TcxLabel;
    cxLabel3: TcxLabel;
    cxDBDateEdit1: TcxDBDateEdit;
    cxDBDateEdit2: TcxDBDateEdit;
    rptRel: TppReport;
    ppTitleBand6: TppTitleBand;
    ppLine1: TppLine;
    ppLine2: TppLine;
    ppLabel1: TppLabel;
    ppSystemVariable2: TppSystemVariable;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand30: TppDetailBand;
    ppDBText3: TppDBText;
    ppDBText4: TppDBText;
    ppFooterBand5: TppFooterBand;
    ppLine3: TppLine;
    ppLine4: TppLine;
    ppSystemVariable1: TppSystemVariable;
    ppSummaryBand2: TppSummaryBand;
    daDataModule1: TdaDataModule;
    ppParameterList1: TppParameterList;
    Designer_Rel: TppDesigner;
    ppRel: TppDBPipeline;
    ppLayoutRel: TppDBPipeline;
    ppDadosLicenca: TppDBPipeline;
    ppDadosLicencappField1: TppField;
    ppDadosLicencappField2: TppField;
    ppDadosLicencappField3: TppField;
    ppDadosLicencappField4: TppField;
    ppDadosLicencappField5: TppField;
    ppDadosLicencappField6: TppField;
    ppDadosLicencappField7: TppField;
    ppDadosLicencappField8: TppField;
    ppDadosLicencappField9: TppField;
    ppDadosLicencappField10: TppField;
    ppDadosLicencappField11: TppField;
    ppDadosLicencappField12: TppField;
    ppDadosLicencappField13: TppField;
    ppDadosLicencappField14: TppField;
    ppDadosLicencappField15: TppField;
    edtRelCODIGO: TIntegerField;
    edtRelREL_EXT_IAGRO: TMemoField;
    edtRelCODIGO2: TIBStringField;
    DtlstRelDATA: TDateField;
    DtlstRelDOC: TIBStringField;
    DtlstRelM_QTDE_1: TFloatField;
    DtlstRelF_QTDE_1: TFloatField;
    DtlstRelM_QTDE_2: TFloatField;
    DtlstRelF_QTDE_2: TFloatField;
    DtlstRelM_QTDE_3: TFloatField;
    DtlstRelF_QTDE_3: TFloatField;
    DtlstRelM_QTDE_4: TFloatField;
    DtlstRelF_QTDE_4: TFloatField;
    DtlstRelM_SALDO_1: TFloatField;
    DtlstRelF_SALDO_1: TFloatField;
    DtlstRelM_SALDO_2: TFloatField;
    DtlstRelF_SALDO_2: TFloatField;
    DtlstRelM_SALDO_3: TFloatField;
    DtlstRelF_SALDO_3: TFloatField;
    DtlstRelM_SALDO_4: TFloatField;
    DtlstRelF_SALDO_4: TFloatField;
    DtlstRelM_QTDE_TOTAL: TFloatField;
    DtlstRelF_QTDE_TOTAL: TFloatField;
    DtlstRelGERAL: TFloatField;
    DtlstRelTERCEIRO: TIBStringField;
    DtlstRelPROPRIEDADE_2: TIBStringField;
    DtlstRelCAB_PROPRIEDADE: TIBStringField;
    DtlstRelCAB_PRODUTOR: TIBStringField;
    DtlstRelCAB_INSC_ESTADUAL: TIBStringField;
    DtlstRelCAB_CIDADE: TIBStringField;
    DtlstRelCAB_UF: TIBStringField;
    DtlstRelCAB_AREA_PASTAGEM: TFloatField;
    ppLabel2: TppLabel;
    ppLabel3: TppLabel;
    ppLabel4: TppLabel;
    ppLabel5: TppLabel;
    ppLabel6: TppLabel;
    ppLabel7: TppLabel;
    ppLabel8: TppLabel;
    ppLabel9: TppLabel;
    ppLabel10: TppLabel;
    ppLabel11: TppLabel;
    ppLabel12: TppLabel;
    ppLabel13: TppLabel;
    ppLabel14: TppLabel;
    ppLabel15: TppLabel;
    ppLabel16: TppLabel;
    ppLabel17: TppLabel;
    ppDBText1: TppDBText;
    ppDBText2: TppDBText;
    ppDBText5: TppDBText;
    ppDBText6: TppDBText;
    ppDBText7: TppDBText;
    ppDBText8: TppDBText;
    ppDBText9: TppDBText;
    ppDBText10: TppDBText;
    ppDBText11: TppDBText;
    ppDBText12: TppDBText;
    ppDBText13: TppDBText;
    ppDBText14: TppDBText;
    ppDBText15: TppDBText;
    ppDBText16: TppDBText;
    ppDBText17: TppDBText;
    ppDBText18: TppDBText;
    ppDBText19: TppDBText;
    ppDBText20: TppDBText;
    ppDBText21: TppDBText;
    ppDBText22: TppDBText;
    ppDBText23: TppDBText;
    ppDBText24: TppDBText;
    ppDBText25: TppDBText;
    ppDBText26: TppDBText;
    ppLabel18: TppLabel;
    ppLabel19: TppLabel;
    ppLabel20: TppLabel;
    ppLabel21: TppLabel;
    ppLabel22: TppLabel;
    ppLabel23: TppLabel;
    ppLabel24: TppLabel;
    ppLabel25: TppLabel;
    ppDBText27: TppDBText;
    ppDBText28: TppDBText;
    ppDBText29: TppDBText;
    ppDBText30: TppDBText;
    ppDBText31: TppDBText;
    SubVacina: TppSubReport;
    ppChildReport1: TppChildReport;
    DtlstRelCAB_DATA1: TDateField;
    DtlstRelCIDADE: TIBStringField;
    DtlstRelUF: TIBStringField;
    DtlstRelCAB_DATA2: TDateField;
    ppDBText32: TppDBText;
    ppDBText33: TppDBText;
    ppDBText34: TppDBText;
    ppDBText35: TppDBText;
    DtlstRelMARCA: TBlobField;
    ppDBImage1: TppDBImage;
    ppLabel26: TppLabel;
    qryRelVacinas: TIBQuery;
    qryRelVacinasDATA: TDateField;
    qryRelVacinasDOC: TIBStringField;
    qryRelVacinasTIPO_VACINA: TIBStringField;
    qryRelVacinasCAMPANHA: TIBStringField;
    qryRelVacinasCOD_CAMPANHA: TIntegerField;
    qryRelVacinasM_QTDE_1: TFloatField;
    qryRelVacinasF_QTDE_1: TFloatField;
    qryRelVacinasM_QTDE_2: TFloatField;
    qryRelVacinasF_QTDE_2: TFloatField;
    qryRelVacinasM_QTDE_3: TFloatField;
    qryRelVacinasF_QTDE_3: TFloatField;
    qryRelVacinasM_QTDE_4: TFloatField;
    qryRelVacinasF_QTDE_4: TFloatField;
    qryRelVacinasM_QTDE_TOTAL: TFloatField;
    qryRelVacinasF_QTDE_TOTAL: TFloatField;
    qryRelVacinasGERAL: TFloatField;
    ppRelVacina: TppDBPipeline;
    dsRelVacinas: TDataSource;
    ppTitleBand1: TppTitleBand;
    ppDetailBand1: TppDetailBand;
    ppSummaryBand1: TppSummaryBand;
    ppHeaderBand2: TppHeaderBand;
    ppLabel27: TppLabel;
    ppLabel28: TppLabel;
    ppLabel29: TppLabel;
    ppLabel30: TppLabel;
    ppLabel31: TppLabel;
    ppLabel32: TppLabel;
    ppLabel33: TppLabel;
    ppLabel34: TppLabel;
    ppLabel35: TppLabel;
    ppLabel36: TppLabel;
    ppLabel37: TppLabel;
    ppLabel38: TppLabel;
    ppLabel39: TppLabel;
    ppLabel41: TppLabel;
    ppLabel42: TppLabel;
    ppDBText36: TppDBText;
    ppDBText37: TppDBText;
    ppDBText38: TppDBText;
    ppDBText39: TppDBText;
    ppDBText40: TppDBText;
    ppDBText41: TppDBText;
    ppDBText42: TppDBText;
    ppDBText43: TppDBText;
    ppDBText44: TppDBText;
    ppDBText45: TppDBText;
    ppDBText46: TppDBText;
    ppDBText47: TppDBText;
    ppDBText48: TppDBText;
    ppDBText49: TppDBText;
    ppDBText50: TppDBText;
    ppLabel40: TppLabel;
    DtlstRelDESCRICAO: TIBStringField;
    DtlstRelM_SALDO_TOTAL: TFloatField;
    DtlstRelF_SALDO_TOTAL: TFloatField;
    DtlstRelVALOR_UNITARIO: TFloatField;
    DtlstRelVALOR_TOTAL: TFloatField;
    procedure ActConfigurarExecute(Sender: TObject);
    procedure ActOKExecute(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmRelExtratoIAGRO: TfrmRelExtratoIAGRO;

implementation

{$R *.dfm}

procedure TfrmRelExtratoIAGRO.ActConfigurarExecute(Sender: TObject);
begin
  inherited;
  ConfigRel(rptRel,Designer_Rel);
end;

procedure TfrmRelExtratoIAGRO.ActOKExecute(Sender: TObject);
begin
  inherited;
  edtRel.close;
  edtRel.parambyname('codigo').value := 1;
  edtRel.Open;

  rptRel.Template.DatabaseSettings.Name := '1';
  rptRel.Template.LoadFromDatabase;

  DtlstRel.Close;
  DtlstRel.ParamByName('propriedade').value := mtbFiltroPROPRIEDADE.AsInteger;
  DtlstRel.ParamByName('data1').value := mtbFiltroDATA1.AsDateTime;
  DtlstRel.ParamByName('data2').value := mtbFiltroDATA2.AsDateTime;
  DtlstRel.Open;

  qryRelVacinas.Close;
  qryRelVacinas.ParamByName('propriedade').value := mtbFiltroPROPRIEDADE.AsInteger;
  qryRelVacinas.ParamByName('data1').value := mtbFiltroDATA1.AsDateTime;
  qryRelVacinas.ParamByName('data2').value := mtbFiltroDATA2.AsDateTime;
  qryRelVacinas.Open;

  rptRel.Print;
end;

procedure TfrmRelExtratoIAGRO.FormShow(Sender: TObject);
begin
  inherited;
  lstProdutores.Close;
  lstProdutores.Open;

  lstPropriedade.Close;
  lstPropriedade.Open;

  mtbFiltroDATA1.Value := date;
  mtbFiltroDATA2.Value := date;
end;

end.
